package zFactory;

import org.eclipse.emf.common.util.EList;

import node1.AbstractTask;
import bP.BP;
import bP.BPFactory;
import genArchi.Node;

public class NodeBusyPeriod implements NodeInterface {

	/**
	 * Attributes
	 */
	private EList<AbstractTask> l_tasks;
	private boolean enableCreate;
	/**
	 * Constructor
	 */
	public NodeBusyPeriod(EList<AbstractTask> l_tasks, boolean enableCreate) 
	{
		this.l_tasks = l_tasks;
		this.enableCreate = enableCreate;
	}
	
	@Override
	public Node createNode() {
		/**/
		BP busyP = BPFactory.eINSTANCE.createBP();

		/**/
		for (AbstractTask at : l_tasks) {

			/* Create local tasks, and set attributes */
			bP.Task t = BPFactory.eINSTANCE.createTask();
			t.setWcet(at.getWcet());
			t.setPeriod(at.getPeriod());

			/* Add to list of tasks*/
			busyP.getTasks().add(t);
		}

		/**/
		return busyP;
	}

	@Override
	public String getNodeName() 
	{
		return "bP.impl.BPImpl";
	}

	@Override
	public void update(Node node) {}

	public boolean isEnable() 
	{
		return this.enableCreate;
	}
}
